#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define N 200
#define RANGE 10
int genArrays(int);
int printArr(int arr[], int len);
int histogram(int arr[], int len); 

int arr[N] = {0};

int main (int argc, char* argv[]) {
	int arr2[RANGE] = {0};
	genArrays(RANGE);
	printArr(arr, sizeof(arr)/sizeof(arr[0]));
	for (int i = 0; i < N; i++) {
		arr2[arr[i]]++;
	}
	printArr(arr2, sizeof(arr2)/sizeof(arr2[0]));
	histogram(arr2, sizeof(arr2)/sizeof(arr2[0]));
	return 0;
}

int histogram(int arr[], int len) {
	for (int i = 0; i < len; i++) {
		printf("%d | ", i);
		for(int j = 0, l = arr[i]; j < l; j++) {
			printf("* ");
		}
		printf("\n");
	}
	return 0;
}

int printArr(int arr[], int len) {
	for (int i = 0; i < len - 1; i++) {
		printf("%d, ", arr[i]);
	}
	printf("%d\n", arr[len -1]);
	return 0;
}

int genArrays(int upper) {
	srand(time(NULL));
	for (int i = 0; i < N; i++) {
		arr[i] = rand() % upper;
	}
	return 0;
}

